import requests

# 目标URL（使用localhost）
url = 'http://localhost:5000/home'  # 或者使用 'http://127.0.0.1:5000/home'

# 要发送的JSON数据
json_data = {
    'k1': '1',
    'k2': '2'
}

try:
    # 发送POST请求
    response = requests.post(url, json=json_data)

    # 检查响应状态码
    response.raise_for_status()

    # 打印响应信息
    print("Status Code:", response.status_code)
    print("Response JSON:", response.json())
    print("Response Type:", type(response))
    print("Raw Response:", response.text)

except requests.exceptions.ConnectionError:
    print("连接错误：请确认Flask服务器是否正在运行")
except requests.exceptions.RequestException as e:
    print(f"请求错误：{e}")
